package com.ruoyi.system.service.news.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.PageHelper;
import com.ruoyi.system.domain.news.NewsMiddlePictureInfo;
import com.ruoyi.system.domain.news.query.NewsMiddlePictureInfoQuery;
import com.ruoyi.system.domain.news.vo.NewsMiddlePictureInfoVo;
import com.ruoyi.system.domain.news.vo.NewsMiddlePictureInfoVo;
import com.ruoyi.system.mapper.news.NewsMiddlePictureInfoMapper;
import com.ruoyi.system.service.news.NewsMiddlePictureInfoService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
@Slf4j
public class NewsMiddlePictureInfoServiceImpl extends ServiceImpl<NewsMiddlePictureInfoMapper, NewsMiddlePictureInfo>
        implements NewsMiddlePictureInfoService {

    @Override
//    @DataScope(deptAlias = "t",userAlias = "t")
    public List<NewsMiddlePictureInfoVo> getNewsMiddlePictureInfoList(NewsMiddlePictureInfoQuery newsMiddlePictureInfoQuery) {
        if (newsMiddlePictureInfoQuery.getIfPage()) {
            PageHelper.startPage(newsMiddlePictureInfoQuery.getPageNum(), newsMiddlePictureInfoQuery.getPageSize());
        }
        List<NewsMiddlePictureInfoVo> newsMiddlePictureInfoVoList = baseMapper.getNewsMiddlePictureInfoList(newsMiddlePictureInfoQuery);
        if (!newsMiddlePictureInfoVoList.isEmpty() && newsMiddlePictureInfoQuery.getId() == null) {
            for (NewsMiddlePictureInfoVo newsMiddlePictureInfoVo:newsMiddlePictureInfoVoList) {
                newsMiddlePictureInfoVo.setContent(null);
            }
        }
        return newsMiddlePictureInfoVoList;
    }
}
